@extends('admin.admin')

@section('content')
        <!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        商品属性设置
        <small>列表</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="/admin"><i class="fa fa-dashboard"></i> 控制面板</a></li>
        <li class="active">商品属性设置</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="row">

        <div class="col-xs-12">
            <div class="box box-primary">
                <div class="box-header">
                    <div class="box-body">

                        <div class="col-xs-2">

                        {!! Form::model('search',array('route' => ['admin.goods_attribute.index'],'method'=>'get','class'=>'form-horizontal')) !!}

                        <div class="form-group">

                            <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
                        </div>
                            {!! Form::close() !!}

                        </div>
                        <div class="col-xs-2">
                            <button type="button" class="btn  btn-danger"  ><i class="icon  glyphicon glyphicon-remove"></i> 查看</button>

                        </div>

                    </div>
                </div>
            </div>
        </div>

        <div class="col-xs-12">
            <div class="box box-primary">
                <div class="box-header">
                    <h3 class="box-title">商品属性列表</h3>
                    <div class="box-tools">
                        <a href="{{route('admin.goods_attribute.create')}}" type="button" class="btn btn-block btn-success btn-xs"><i class="icon  glyphicon glyphicon-plus"></i> 添加</a>
                    </div>


                </div>
                <!-- /.box-header -->
                {!! Form::model($goodsAttribute,['route' => 'admin.goods_attribute.sort', 'method'=>'post', 'class'=>'form-horizontal']) !!}
                <div class="box-body table-responsive no-padding">
                    <table class="table table-hover">
                        <tr>
                            <th style="width:50px;">排序</th>                                                    
                            <th style="width:50px;">ID</th>
                            <th>商品属性名称</th>
                            <th>商品类型</th>
                            <th>属性值录入方式</th> 
                            <th>属性可选值</th>  
                            <th style="width: 250px;">操作</th>

                        </tr>
                        @foreach ($goodsAttribute as $item)
                        <tr>
                            <td>{!! Form::text('sort_order['.$item->attribute_id.']',$item->sort_order,['class'=>'input-mini','style'=>'text-align:center;width: 30px;height:30px;margin-bottom:0px;'])!!}</td>     
                            <td>{{$item->attribute_id}}</td>
                            <td>{{$item->attribute_name}}</td>
                            <td>{{$type_name}}</td> 
                            <td>{{$item->attribute_input_type}}</td>              
                            <td>{{$item->attribute_values}}</td>
                       
                            <td>
                                <a href="{{Route('admin.goods_attribute.edit',$item->attribute_id)}}" type="button" class="btn  btn-default btn-xs"><i class="icon  glyphicon glyphicon-edit"></i> 修改</a>

                                <button type="button" class="btn  btn-danger btn-xs"  data-toggle="modal" data-target="#modal{{$item->attribute_id}}"><i class="icon  glyphicon glyphicon-remove"></i> 删除</button>

                                <div id="modal{{$item->attribute_id}}" class="modal fade">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                <h4 class="modal-title">删除警告:</h4>
                                            </div>
                                            <div class="modal-body">
                                                <p>确认要删除属性[{{$item->attribute_name}}]吗?</p>
                                            </div>
                                            <div class="modal-footer">


                                                
                                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                <a class="btn btn-danger01" itemid="{{$item->attribute_id}}">删除</a>

                                            </div>
                                        </div><!-- /.modal-content -->
                                    </div><!-- /.modal-dialog -->
                                </div><!-- /.modal -->

                            </td>
                        </tr>
                        @endforeach

                    </table>
                </div>

                <!-- /.box-body -->
                <input type="hidden" name="do_submit" value="1"/>
                <input name='submit' type='submit' class="btn btn-success" style="margin:5px" value='排序'>
                {!!Form::close()   !!}
            </div>
            <!-- /.box -->
            {!! $goodsAttribute->render() !!}
        </div>
    </div>



</section>
<!-- /.content -->

<script>

        $('.btn-danger01').on('click',function(e){
            e.preventDefault();
            var attribute_id = $(this).attr("itemid");
            if(!attribute_id) return false;

            $.ajax({
                url:'/admin/goods_attribute/'+attribute_id+"?"+Math.random(),
                type:'delete',
                data:{attribute_id:attribute_id,'_token':'{{csrf_token()}}'},
                dataType:"json",
                success:function(result){                    

                    if(result.status){
                        $('#del_alert').modal();
                        $("#ok").hide();
                        $("#no").show();
                        $("#message_content").html(result.info);
                    }else{
                        window.location.reload();
                    }

                }

            });

        });      
        
        
    </script>

<script>
    $('.btn-danger').on('click',function(){
        console.log('11');
    });
</script>
@endsection